services:
  agent:
    command: sh -c 'bin/wait && python -m deeppavlov_agent.run agent.pipeline_config=assistant_dists/dream_kg/pipeline_conf.json'
    environment:
      WAIT_HOSTS: "sentence-ranker:8128, sentseg:8011, ranking-based-response-selector:8002,
          ner:8021, entity-linking:8075, combined-classification:8087, entity-detection:8103,
          property-extraction:8136, custom-entity-linking:8153, terminusdb-server:6363, user-knowledge-memorizer:8020,
          dff-user-kg-skill:8028, dff-travel-italy-skill:8025"
      WAIT_HOSTS_TIMEOUT: ${WAIT_TIMEOUT:-480}
      HIGH_PRIORITY_INTENTS: 1
      RESTRICTION_FOR_SENSITIVE_CASE: 1
      ALWAYS_TURN_ON_ALL_SKILLS: 0
      LANGUAGE: EN
      FALLBACK_FILE: fallbacks_dream_en.json

  sentence-ranker:
    env_file: [ .env ]
    build:
      args:
        SERVICE_PORT: 8128
        SERVICE_NAME: sentence_ranker
        PRETRAINED_MODEL_NAME_OR_PATH: sentence-transformers/all-MiniLM-L6-v2
      context: ./services/sentence_ranker/
    command: flask run -h 0.0.0.0 -p 8128
    environment:
      - CUDA_VISIBLE_DEVICES=0
      - FLASK_APP=server
    deploy:
      resources:
        limits:
          memory: 3G
        reservations:
          memory: 3G

  sentseg:
    env_file: [ .env ]
    build:
      context: ./annotators/SentSeg/
    command: flask run -h 0.0.0.0 -p 8011
    environment:
      - FLASK_APP=server
    deploy:
      resources:
        limits:
          memory: 1.5G
        reservations:
          memory: 1.5G

  ranking-based-response-selector:
    env_file: [ .env ]
    build:
      args:
        SERVICE_PORT: 8002
        SERVICE_NAME: response_selector
        LANGUAGE: EN
        SENTENCE_RANKER_ANNOTATION_NAME: sentence_ranker
        SENTENCE_RANKER_SERVICE_URL: http://sentence-ranker:8128/respond
        SENTENCE_RANKER_TIMEOUT: 3
        N_UTTERANCES_CONTEXT: 5
        FILTER_TOXIC_OR_BADLISTED: 1
      context: .
      dockerfile: ./response_selectors/ranking_based_response_selector/Dockerfile
    command: flask run -h 0.0.0.0 -p 8002
    environment:
      - FLASK_APP=server
    deploy:
      resources:
        limits:
          memory: 100M
        reservations:
          memory: 100M

  ner:
    env_file: [ .env ]
    build:
      args:
        CONFIG: ner_case_agnostic_multilingual_bert_base_extended.json
        SERVICE_PORT: 8021
        SRC_DIR: annotators/NER_deeppavlov
        COMMIT: f5117cd9ad1e64f6c2d970ecaa42fc09ccb23144
      context: ./
      dockerfile: annotators/NER_deeppavlov/Dockerfile
    command: flask run -h 0.0.0.0 -p 8021
    environment:
      - FLASK_APP=server
      - CUDA_VISIBLE_DEVICES=0
    tty: true
    deploy:
      resources:
        limits:
          memory: 2G
        reservations:
          memory: 2G

  entity-linking:
    env_file: [ .env ]
    build:
      args:
        SERVICE_PORT: 8075
        SERVICE_NAME: entity_linking
        CONFIG: entity_linking_eng.json
        SRC_DIR: annotators/entity_linking
      context: ./
      dockerfile: annotators/entity_linking/Dockerfile
    environment:
      - CUDA_VISIBLE_DEVICES=0
    deploy:
      resources:
        limits:
          memory: 2.5G
        reservations:
          memory: 2.5G

  combined-classification:
    env_file: [ .env ]
    build:
      args:
        SERVICE_PORT: 8087
        SERVICE_NAME: combined_classification
        CONFIG: combined_classifier.json
      context: .
      dockerfile: ./annotators/combined_classification/Dockerfile
    environment:
      - CUDA_VISIBLE_DEVICES=0
    deploy:
      resources:
        limits:
          memory: 2G
        reservations:
          memory: 2G

  entity-detection:
    env_file: [ .env ]
    build:
      args:
        SERVICE_NAME: entity_detection
        SEQ_TAG_CONFIG: wikipedia_entity_detection_distilbert.json
        CONFIG: entity_detection_eng.json
        LOWERCASE: 1
        SERVICE_PORT: 8103
        SRC_DIR: annotators/entity_detection/
        FINEGRAINED: 0
      context: ./
      dockerfile: annotators/entity_detection/Dockerfile
    command: flask run -h 0.0.0.0 -p 8103
    environment:
      - FLASK_APP=server
      - CUDA_VISIBLE_DEVICES=0
    deploy:
      resources:
        limits:
          memory: 2.5G
        reservations:
          memory: 2.5G

  property-extraction:
    env_file: [.env]
    build:
      args:
        CONFIG_T5: t5_generative_ie_lite_infer.json
        CONFIG_REL_RANKER: rel_ranking_roberta.json
        SERVICE_PORT: 8136
        SRC_DIR: annotators/property_extraction/
        SERVICE_NAME: property_extraction
      context: ./
      dockerfile: annotators/property_extraction/Dockerfile
    command: flask run -h 0.0.0.0 -p 8136
    environment:
      - FLASK_APP=server
      - CUDA_VISIBLE_DEVICES=0
    deploy:
      resources:
        limits:
          memory: 7G
        reservations:
          memory: 7G

  custom-entity-linking:
    env_file: [.env]
    build:
      args:
        CONFIG: custom_entity_linking.json
        SERVICE_PORT: 8153
        SRC_DIR: annotators/custom_entity_linking
      context: ./
      dockerfile: annotators/custom_entity_linking/Dockerfile
    deploy:
      resources:
        limits:
          memory: 128M
        reservations:
          memory: 128M

  terminusdb-server:
    image: terminusdb/terminusdb-server:v10.1.10

  user-knowledge-memorizer:
    env_file: [ .env ]
    build:
      args:
        SERVICE_PORT: 8020
        SRC_DIR: annotators/user_knowledge_memorizer/
        SERVICE_NAME: user_knowledge_memorizer
        TERMINUSDB_SERVER_URL: http://terminusdb-server:6363
        TERMINUSDB_SERVER_PASSWORD: root
        TERMINUSDB_SERVER_TEAM: admin
        TERMINUSDB_SERVER_DB: user_knowledge_db
        USER_KM_SERVICE_CONFIG: index_load_path.json
        GENERATIVE_SERVICE_URL: http://openai-api-chatgpt:8145/respond
        GENERATIVE_SERVICE_CONFIG: openai-chatgpt.json
        GENERATIVE_SERVICE_TIMEOUT: 5
        SENTENCE_RANKER_URL: http://sentence-ranker:8128/respond
        SENTENCE_RANKER_TIMEOUT: 5
        RELEVANT_KNOWLEDGE_THRESHOLD: 0.5
        ENVVARS_TO_SEND: OPENAI_API_KEY
        USE_KG_DATA: 0
      context: ./
      dockerfile: annotators/user_knowledge_memorizer/Dockerfile
    command: flask run -h 0.0.0.0 -p 8020
    environment:
      - FLASK_APP=server
    deploy:
      resources:
        limits:
          memory: 256M
        reservations:
          memory: 256M

  dff-user-kg-skill:
    env_file: [ .env ]
    build:
      args:
        SERVICE_PORT: 8028
        SERVICE_NAME: dff_user_kg_skill
      context: .
      dockerfile: ./skills/dff_user_kg_skill/Dockerfile
    command: gunicorn --workers=1 server:app -b 0.0.0.0:8028
    deploy:
      resources:
        limits:
          memory: 128M
        reservations:
          memory: 128M

  dff-travel-italy-skill:
    env_file: [ .env ]
    build:
      args:
        SERVICE_PORT: 8025
        SERVICE_NAME: dff_travel_italy_skill
        TERMINUSDB_SERVER_URL: http://terminusdb-server:6363
        TERMINUSDB_SERVER_PASSWORD: root
        TERMINUSDB_SERVER_TEAM: admin
        TERMINUSDB_SERVER_DB: user_knowledge_db
      context: .
      dockerfile: ./skills/dff_travel_italy_skill/Dockerfile
    command: gunicorn --workers=1 server:app -b 0.0.0.0:8025 --reload
version: '3.7'
